package Three;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		double[] arr = new double[n];
		for (int i = 0; i < n; i++) {
			arr[i] = scan.nextDouble();
		}
		while (scan.hasNext()) {
			try {
				int begin = Integer.parseInt(scan.next());
				int end = Integer.parseInt(scan.next());
				System.out.println(ArrayUtils.findMax(arr, begin, end));
			} catch (NumberFormatException e) {
				break;
			} catch (Exception e) {
				System.out.println(e);
			}
		}
		try {
			System.out.println(ArrayUtils.class.getDeclaredMethod("findMax", double[].class, int.class, int.class));
		} catch (Exception e1) {

		}
		scan.close();
	}

}
